(function () {
    'use strict';
    angular.module('module.business')
        .controller('EvaluationDataController', EvaluationDataController);
    EvaluationDataController.$inject = ['$rootScope', '$scope', '$filter', '$uibModal', '$http', '$state', 'i18nService'];

    function EvaluationDataController($rootScope, $scope, $filter, $uibModal, $http, $state, i18nService) {
        var vm = $scope;
        vm.activate = activate;     //初始化
        vm.retrieveAllEvaluationData = retrieveAllEvaluationData;


        vm.gridOptions = {
            multiSelect: true,                                           //多选
            enableRowSelection: true,                                  //允许选中行
            //showGridFooter:true,
            enableRowHeaderSelection: false,//允许通过点击行首选中行
            enableColumnResizing : true,//设置宽度
            enableGridMenu: true,
            enableFullRowSelection: true,                              //允许通过点击行任意位置选中行
            modifierKeysToMultiSelect: true,                           //只允许通过键盘辅助多选(前提是允许多选)
            paginationPageSize: 10,
            paginationPageSizes: [10, 20, 50]

        };
        i18nService.setCurrentLang('zh-cn');
        vm.gridOptions.onRegisterApi = onRegisterApi;
        vm.gridOptions.columnDefs = [
            {field: 'NO', visible: true, name: '序号', pinnedLeft: true,cellTooltip: true,headerTooltip: true,width:'70'},
            {field: 'REPORT_NO', visible: true, name: '测评报告编号', pinnedLeft: true,cellTooltip: true,headerTooltip: true,width:'130'},
            {field: 'SYSTEM_NAME', visible: true, name: '系统名称', pinnedLeft: true,cellTooltip: true,headerTooltip: true},
            {field: 'CERTIFICATE_NO', visible: true, name: '备案证明编号', pinnedLeft: true,cellTooltip: true,headerTooltip: true,width:'140'},
            {field: 'SYSTEM_LEVEL', visible: true, name: '系统级别', pinnedLeft: true,cellTooltip: true,headerTooltip: true,width:'100'},
            {field: 'SUPER_UNIT', visible: true, name: '所属单位', pinnedLeft: true,cellTooltip: true,headerTooltip: true},
            {field: 'EVALUATE_ORG', visible: true, name: '测评机构', pinnedLeft: true,cellTooltip: true,headerTooltip: true},
            {field: 'EVALUATE_TIME', visible: true, name: '测评时间', pinnedLeft: true,cellTooltip: true,headerTooltip: true,width:'160'},
            {field: 'EVALUATE_RESULT', visible: true, name: '测评结果', pinnedLeft: true,cellTooltip: true,headerTooltip: true,width:'90'},
            {field: 'EVALUATE_SCORE', visible: true, name: '测评得分', pinnedLeft: true,cellTooltip: true,headerTooltip: true,width:'90'},
            {field: 'ENTRY_TIME', visible: true, name: '入库时间', pinnedLeft: true,cellTooltip: true,headerTooltip: true,width:'160'}

        ];

        activate();

        return vm;

        function onRegisterApi(gridApi) {
            //set gridApi on scope
            vm.gridApi = gridApi;
        }

        function retrieveAllEvaluationData() {
            $http.get('app/module/business/evaluation/data/evaluation-data.json').then(function(data){
                vm.gridOptions = data;
            });
        }

        function activate(){
            $scope.$on('$viewContentLoaded', function () {
                App.initAjax(); // initialize core components
            });
            $rootScope.settings.layout.pageContentWhite = true;
            $rootScope.settings.layout.pageBodySolid = true;
            $rootScope.settings.layout.pageSidebarClosed = false;
            retrieveAllEvaluationData();
        }
    }
})();